# 最大子数组和
class Solution:
    def maxSubArray(self, nums: List[int]) -> int:
        n=len(nums)
        result=nums[0]
        for i in range(1,n):
            if nums[i-1] > 0:
                nums[i]+=nums[i-1]
            result=max(result,nums[i])
        return result

# 最长公共子序列
class Solution:
    def longestCommonSubsequence(self, text1: str, text2: str) -> int:
        m,n=len(text1),len(text2)
        matrix=[[0]*(n+1) for _ in range(m+1)]
        for i in range(1,m+1):
            for j in range(1,n+1):
                if text1[i-1] == text2[j-1]:
                    matrix[i][j]=matrix[i-1][j-1]+1
                else:
                    matrix[i][j]=max(matrix[i-1][j],matrix[i][j-1])
        return matrix[-1][-1]
